package com.xxx.delayjob.controller;

import com.xxx.delayjob.service.RedissonDelayQueue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Redisson延时消息
 */
@RestController
public class RedissonDelayQueueController {

    @Resource
    private RedissonDelayQueue redissonDelayQueue;

    /**
     * http://localhost:8080/redisson/add?task=sanyou
     */
    @GetMapping("/redisson/add")
    public void addTask(@RequestParam("task") String task) {
        // 提交延时任务：5s
        redissonDelayQueue.offerTask(task, 5);
    }

}
